using System;
using System.Collections.Generic;
using System.Text;

namespace MicroFractal.iTunesBrowser.Business
{
    /// <summary>
    /// Representa un artista.
    /// </summary>
    public class Artist : IDownloadableObject
    {

        #region Constructors

        public Artist(string name)
        {
            _name = name;
            _albums = new List<Album>();
        }

        #endregion

        #region Properties

        private List<Album> _albums;
        /// <summary>
        /// Obtiene o establece los albums del artista.
        /// </summary>
        public List<Album> Albums
        {
            get { return _albums; }
            set { _albums = value; }
        }

        private string _name;
        /// <summary>
        /// Obtiene o establece el nombre del artista.
        /// </summary>
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        #endregion

        #region Overrides

        public override bool Equals(object obj)
        {
            if (obj != null && obj is Artist)
            {
                return _name == ((Artist)obj)._name;
            }
            return false;
        }

        public override string ToString()
        {
            return _name;
        }

        #endregion

        public int ItemsCount
        {
            get { return this.GetDownloadableSongs().Count; }
        }

        #region IDownloadableObject Members

        public IList<Song> GetDownloadableSongs()
        {
            List<Song> result = new List<Song>();
            foreach (Album a in _albums)
            {
                result.AddRange(a.GetDownloadableSongs());
            }
            return result;
        }

        #endregion
    }
}
